Within the context of computer systems, many types of resources can be shared among processes. However, many resources, though sharable, may not be accessed in certain ways by more than one process at any given time. For example, resources such as data blocks of a storage medium or tables stored on a storage medium may be concurrently accessed in some ways (e.g. read) by multiple processes, but accessed in other ways (e.g. written to) by only one process at a time. Consequently, mechanisms have been developed which control access to resources.
One such mechanism is referred to as a lock. A lock is a data structure that indicates that a particular process has been granted certain rights with respect to a resource. There are many types of locks. Some types of locks may be shared on the same resource by many processes, while other types of locks prevent any other locks from being granted on the same resource.
The entity responsible for granting locks on resources is referred to as a lock manager. In a single node database system, a lock manager will typically include one or more processes on a node. In a multiple-node system, such as a multi-processing machine, a clustered system, or a local area network, a lock manager may include processes distributed over numerous nodes. A lock manager that includes components that reside on two or more nodes is referred to as a distributed lock manager.
In computer science, deadlock refers to a condition when two or more processes are each waiting for another to release a resource, or more than two processes are waiting for resources in a circular chain. Deadlock is a common problem in multiprocessing where many processes share a specific type of mutually exclusive resource lock.
For example, when processes are executed with different operating system priorities or processes are given different scheduling treatments, a deadlock or starvation on processes for resources can happen, which can lead to database hang. In one example, a process P1 waiting for resources may be scheduled to run on a frequent basis but process P2 is holding the resources (needed by P1). If process P2 is not scheduled enough time or is not scheduled to be executed by a processor at all, P2 cannot finish its task and thus cannot release the resources it is holding. Hence P1 is in a hang state and may time out, and P1 and P2 are in a deadlock/starvation situation.